var currentUser
var newvue=new Vue({
	el:"body",
	data:{
		shop:[],
		sing:""
	},
	methods:{
		back: function() {
			window.history.back()
		},
		singIn:function(){
			location.href="../Sign in/signin.html"
		}
	}
})
getnew()
function getnew(){
	var APP_ID = 'c4w6bVvWfh8xxcmkBE1G0gIt-gzGzoHsz';
	var APP_KEY = 'JBikg4Ksk76zcTi5BKYWvTJF';
	AV.init({
		appId: APP_ID,
		appKey: APP_KEY
	});
	sing()
}
function sing(){
	currentUser = AV.User.current();
	if(currentUser){
		newvue.sing=true
		getShop()
	}else{
		newvue.sing=false
	}
}

function getShop(){
	var query = new AV.Query('ELM_order');
	query.include('owner');
	query.descending('createdAt');
	query.find().then(function(products) {
		for(var i = 0; i < products.length; i++) {
			if(products[i].attributes.if_pay==true&&products[i].attributes.username==currentUser.attributes.username){
			var jop = {
				arr:products[i].attributes.products_data,
				shopname: products[i].attributes.shop_name,
				sendprice: products[i].attributes.shop_sendprice,
				shopimg: products[i].attributes.shopimg,
				totle: products[i].attributes.totle,
			}
			newvue.shop.push(jop);
			}
	}
		console.log(newvue.shop)
	}).catch(function(error) {
		alert(JSON.stringify(error));
	});
}
